package com.xn.myyxcampus.utils;

import java.io.File;

public class FileHelper {
	// 删除文件和目录
	public static void clearFiles(String workspaceRootPath) {
		File file = new File(workspaceRootPath);
		File[] f = file.listFiles();
		if (f.length != 0) {
			for (int index = 0; index < f.length; index++) {
				f[index].deleteOnExit();
			}
		}
	}
	
	public static boolean deleteDir(File dir) {
		if(dir.isDirectory()) {
			String[] children = dir.list();
			for(int i = 0;i<children.length;i++) {
				boolean success = deleteDir(new File(dir,children[i]));
				if(!success) {
					return false;
				}
			}
		}
		return dir.delete();
	}
}
